#include <stdio.h>
int main()
{
    int year, month;
    scanf("%d %d", &year, &month);
    if (month == 2) // need to check leap year
    {
        if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) // leap year
            printf("29\n");

        else // not leap year
            printf("28\n");
    }
    else
    {
        if (month == 4 || month == 6 || month == 9 || month == 11)
        {
            printf("30\n");
        }
        else
        {
            printf("31\n");
        }
    }

    return 0;
}